package com.medical.doctor.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.medical.doctor.entity.DoctorLabelEntity;
import com.medical.doctor.service.DoctorLabelService;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.R;



/**
 * 
 *
 * @author qzy
 * @email qzy@gmail.com
 * @date 2021-08-20 14:14:03
 */
@RestController
@RequestMapping("doctor/label")
public class DoctorLabelController {
    @Autowired
    private DoctorLabelService doctorLabelService;

    /**
    * 患者快速问诊页面
    * */
    @PostMapping("findByName")
    public List<DoctorLabelEntity> queryPageByName(
            @RequestBody DoctorLabelEntity doctorLabelEntity
    ){
        return doctorLabelService.queryPageByName(doctorLabelEntity);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = doctorLabelService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{labelId}")
    public R info(@PathVariable("labelId") Integer labelId){
		DoctorLabelEntity doctorLabel = doctorLabelService.getById(labelId);

        return R.ok().put("doctorLabel", doctorLabel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DoctorLabelEntity doctorLabel){
		doctorLabelService.save(doctorLabel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DoctorLabelEntity doctorLabel){
		doctorLabelService.updateById(doctorLabel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] labelIds){
		doctorLabelService.removeByIds(Arrays.asList(labelIds));

        return R.ok();
    }

}
